package com.dayfly.tip.ao.impl;

import java.util.List;

import com.dayfly.tip.ao.BaseAO;
import com.dayfly.tip.ao.RecordAO;
import com.dayfly.tip.dao.RecordDAO;
import com.dayfly.tip.model.CommonResult;
import com.dayfly.tip.model.RecordDO;
import com.dayfly.tip.model.Result;

public class RecordAOImpl extends BaseAO implements RecordAO {

	private RecordDAO recordDAO;

	public void setRecordDAO(RecordDAO recordDAO) {
		this.recordDAO = recordDAO;
	}

	@Override
	public Result record(RecordDO record) {
		Result result = new CommonResult(false);
		recordDAO.record(record);
		result.setSuccess(true);
		result.put("re", "helloWorld!");
		return result;
	}

	@Override
	public Result getRecordByUserId(long userId) {
		Result result = new CommonResult(false);
		List<RecordDO> records = recordDAO.getRecordByUserId(userId);
		result.put("records", records);
		result.setSuccess(true);
		return result;
	}

	@Override
	public Result getRecordById(long recordId) {
		Result result = new CommonResult(false);
		RecordDO record = recordDAO.getRecordById(recordId);
		result.put("record", record);
		result.setSuccess(true);
		return result;
	}

	@Override
	public Result deleteRecordById(long recordId) {
		Result result = new CommonResult(false);
		recordDAO.deleteRecordById(recordId);
		result.setSuccess(true);
		return result;
	}

	@Override
	public Result updateRecord(RecordDO record) {
		Result result = new CommonResult(false);
		recordDAO.updateRecord(record);
		result.setSuccess(true);
		return result;
	}
}
